package com.tenghu.sbm;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger启动类
 * @author Arvin
 * @date 2017/12/9 15:03
 */

@Configuration
@EnableSwagger2
public class Swagger2 {

    /**
     * 创建客户信息接口文档
     * @return
     */
    @Bean
    public Docket createRestCusApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("cus")
                .apiInfo(createCusApiInfo())
                .select()
                .paths(PathSelectors.any())
                .apis(RequestHandlerSelectors.basePackage("com.tenghu.sbm.cus"))
                .build();
    }

    /**
     * 创建客户信息接口信息
     * @return
     */
    private ApiInfo createCusApiInfo(){
        return new ApiInfoBuilder()
                .title("客户信息接口")
                .description("与客户所有相关操作接口")
                .contact(new Contact("Arvin","http://blog.csdn.net/tenghu8888","libiaohu@126.com"))
                .version("1.0")
                .build();
    }
}
